<html>
<head>
    <#assign basePath=request.contextPath>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台管理系统</title>
    <link href="${basePath}/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="${basePath}/bootstrap/css/font-awesome.min.css" rel="stylesheet">
    <link href="${basePath}/bootstrap/css/form.lzy.css" rel="stylesheet">
    <link href="${basePath}/bootstrap/css/good.lzy.css" rel="stylesheet">
    <style>
        #page-wrapper h1{ display: block; margin-bottom: 20px; border-bottom:1px solid #999; font-size: 16px; padding-left:2px; font-weight: bold; line-height: 35px;}
        select.year,select.mouth{ width: 100px;}
        .line{display: inline-block;}
    </style>
</head>
<body>

<div id="page-wrapper" >
    <div class="panel panel-f5">
        <div class="panel-body row">
            <form id="Form" class="form-horizontal" method="post">
                <input type="hidden" id="_ctx" value="${basePath}"/>
                <input type="hidden" name="orderId" value="${orderId}" />
                <div class="form-group">
                    <span class="control-label col-sm-2 col-xs-3  detail-span">操作备注：</span>
                    <div class="col-sm-10 col-xs-9">
                        <textarea class="form-control" rows="5" cols="40" name="remark" maxlength="500" placeholder="可填写备注，如用户款项通过线下打款已到账，银行流水号：XXXXXX"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <span class="control-label col-sm-2 col-xs-3 detail-span">上传凭证：</span>
                    <div class="col-sm-10 col-xs-9">
                        <input type="file" data-action="goods" data-image="images" onchange="uploadImg(this,true)">
                        <span class="text-warning">可上传银行到账凭证截图</span>
                    </div>
                </div>
                <div class="form-group">
                    <span class="control-label col-sm-2 col-xs-3 detail-span"></span>
                    <div class="col-sm-10 col-xs-9">注：请于销售员沟通清楚后再点击确定按钮完结订单，请务必谨慎操作！</div>
                </div>

                <hr>
                <div class="form-group">
                    <span class="control-label col-sm-2 col-xs-3"></span>
                    <div class="col-sm-10 col-xs-9">
                        <button type="button" class="btn btn-success" onclick="submitForm();"><i class="fa fa-check"></i> 确定</button>&nbsp;
                        <button type="button" class="btn btn-info" onclick="goBack()"><i class="fa fa-close"></i>返回</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="${basePath}/bootstrap/js/jquery.js" type="text/javascript"></script>
<script src="${basePath}/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="${basePath}/bootstrap/plugin/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/bootstrap-validator/0.5.3/js/bootstrapValidator.min.js"></script>
<script type="text/javascript">
    $(window).bootstrapValidator || document.write('<script src="${basePath}/bootstrap/js/bootstrapValidator.min.js"><\/script>');
</script>
<script src="${basePath}/bootstrap/js/common.js" type="text/javascript"></script>
<script>
    function goBack(){
        parent.layer.closeAll();
    }

    function submitForm() {
        var bsVal = $("#Form").data('bootstrapValidator');
        bsVal.validate();
        if(bsVal.isValid()){
            $.ajax({
                type : 'POST',
                dataType: 'json',
                url:  '${basePath}/admin/order/product/offline/submit',
                data: $("#Form").serialize(),
                success: function (data) {
                    if(data.code == "0"){
                        layer.alert("操作成功", {
                            icon : 1
                        },function(){
                            layer.closeAll();
                            parent.window.location.reload();
                        });
                    }else{
                        layer.alert(data.desc, {
                            icon : 5
                        });
                    }
                },
                error: function(){
                    layer.alert('系统错误', {
                        icon : 5
                    });
                }
            });

        }
        else{
            var smallTop = $("small:visible").eq(0).offset().top - 50;
            $("html,body").animate({scrollTop:smallTop},300);
        }
    }

    //表单验证
    $('#Form').bootstrapValidator({
        fields: {
            remark: {
                validators: {
                    notEmpty: {
                        message: '请输入备注'
                    }
                }
            },
            banner: {
                trigger:"change",
                validators: {
                    notEmpty: {
                        message: '请上传凭证'
                    }
                }
            }
        }
    });
</script>
</body>
</html>